package com.info33.platform.system.dic.entity;

import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonView;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.info33.platform.common.mvc.entity.BaseEntity;
import com.info33.platform.system.dic.dto.SysDicDTO;
import com.info33.platform.system.dic.vo.SysDicVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

/**
 * 系统 - 字典 v2
 *
 * @author nyj2one
 * @since 2022-11-23 11:08:42
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
public class SysDic extends BaseEntity {

    private static final long serialVersionUID = 211162670362877994L;

    /**
     * 模块索引
     */
    @JsonView({SysDicDTO.PcPage.class,
            SysDicDTO.PcAdd.class,
            SysDicDTO.OpenList.class,
            SysDicDTO.OpenTree.class,
            SysDicDTO.PcListByMods.class})
    @NotEmpty(
            message = "模块索引不能为空",
            groups = {
                    SysDicDTO.PcPage.class,
                    SysDicDTO.PcAdd.class,
                    SysDicDTO.OpenList.class,
                    SysDicDTO.OpenTree.class,
                    SysDicDTO.PcListByMods.class})
    @ApiModelProperty(value = "模块索引")
    private String modIndex;

    /**
     * 父 id
     */
    @JsonView({SysDicDTO.PcPage.class,
            SysDicDTO.PcAdd.class})
    @NotNull(
            message = "父 id 不能为空",
            groups = {SysDicDTO.PcPage.class,
                    SysDicDTO.PcAdd.class})
    @ApiModelProperty(value = "父 id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long pid;

    /**
     * 树结构编码 16 进制
     */
    @JsonView({SysDicVO.PcTree.class,
            SysDicVO.PcList.class,
            SysDicVO.PcListByMods.class,
            SysDicVO.OpenList.class,
            SysDicVO.OpenTree.class,
            SysDicVO.OpenListByMods.class})
    @ApiModelProperty(value = "树结构编码 16 进制")
    private String treeCode;

    /**
     * 对所有租户开放：1/是、0/否
     */
    @JsonView({SysDicDTO.PcAdd.class,
            SysDicDTO.PcEdit.class})
    @ApiModelProperty(value = "对所有租户开放：1/是、0/否")
    private Boolean common;

    /**
     * 字典键
     */
    @JsonView({SysDicDTO.PcAdd.class,
            SysDicDTO.PcEdit.class,

            SysDicVO.PcTree.class,
            SysDicVO.PcList.class,
            SysDicVO.PcListByMods.class,
            SysDicVO.OpenList.class,
            SysDicVO.OpenTree.class,
            SysDicVO.OpenListByMods.class})
    @NotEmpty(
            message = "字典键不能为空",
            groups = {SysDicDTO.PcAdd.class,
                    SysDicDTO.PcEdit.class})
    @ApiModelProperty(value = "字典键")
    private String dicKey;

    /**
     * 字典值
     */
    @JsonView({SysDicDTO.PcAdd.class,
            SysDicDTO.PcEdit.class,

            SysDicVO.PcTree.class,
            SysDicVO.PcList.class,
            SysDicVO.PcListByMods.class,
            SysDicVO.OpenList.class,
            SysDicVO.OpenTree.class,
            SysDicVO.OpenListByMods.class})
    @ApiModelProperty(value = "字典值")
    private String dicVal;

    /**
     * 逻辑删
     */
    @JsonIgnore
    @TableLogic
    @ApiModelProperty(value = "逻辑删")
    private Boolean deleted;

}
